import ticket.MovieTicket;
import ticket.discount.ChildrenDiscountStrategy;
import ticket.discount.DiscountStrategy;
import ticket.discount.StudentDiscountStrategy;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {

    private static Logger logger = LogManager.getLogger(Main.class.getName());

    public static void main(String[] args) {
        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.
        System.out.println("Hello and welcome!");
        //new一个上文对象
        MovieTicket movieTicket = new MovieTicket();
        movieTicket.setOriginalPrice(120.0);
        //new一个策略模式对象，然后注入上下文
        DiscountStrategy strategy = new StudentDiscountStrategy();
        movieTicket.setDiscountStrategy(strategy);

        //调用上下文计算打折票价的方法
        movieTicket.discountCalculate();

        logger.debug("学生票1张，原价："+movieTicket.getOriginalPrice()+"，打折后价格"+movieTicket.getDiscountPrice());

        //卖一张儿童票
        strategy = new ChildrenDiscountStrategy();
        //
        movieTicket.setDiscountStrategy(strategy);
        //
        movieTicket.discountCalculate();

        logger.debug("儿童票1张，原价："+movieTicket.getOriginalPrice()+"，打折后价格"+movieTicket.getDiscountPrice());

    }
}